package com.dpmc.service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.naming.InitialContext;
import javax.naming.NamingException;
 
import com.svc.OpenEJBsvc;

public class AccountInit {
	public static void main(String[] args) throws NamingException { 
		 InitialContext ctx = OpenEJBsvc.openEJB_InitialContext();   
		 SVC_CWGLLocal svc = (SVC_CWGLLocal) ctx.lookup("SVC_CWGLLocal");
		 init(svc,"TB_SHGL_SHJBXX");
		 init(svc,"TB_HYKGL_JBXX"); 
		 init(svc,"TB_QDSGL_JBXX");
		 init(svc,"TB_HYKGL_FKQDS");
		 init(svc,"TB_YHGL_SKYH");
	}
	public static void init(SVC_CWGLLocal svc,String tbname) {
		 StringBuffer hql = new StringBuffer("SELECT ID FROM ");
         hql.append(tbname);
         hql.append(" t WHERE NOT EXISTS (SELECT 1 FROM TB_CWGL_ZH zh WHERE zh.ZHLX='");
         hql.append(tbname);
         hql.append("' AND zh.GLID=t.ID) "); 
         
         List list = svc.getResultList(hql.toString());
         for(Object item:list){
	         Map cwzh = new HashMap();
	 		 cwzh.put("ZHLX", tbname);
	 		 cwzh.put("GLID",item); 
	 		 cwzh.put("OPID", "402880713294f1a8013294f1a8930000");
	 		 cwzh.put("OP_TIME", new Date());
	 		 svc.ADD_ZH(cwzh);
         } 
	}
	
	
	
}
